class Integer
  def primesUpto
    num = [0, 0] + (2..self).to_a
    (2..self).each do |i|
      if num[i] != 0
        (i**2..self).step(i) {|m| num[m] = 0}
      end
    end
    primes = num.find_all {|m| m != 0}
    return primes
  end
end


a1 = 13.primesUpto
a2 = 29.primesUpto
a3 = 65.primesUpto

puts(a1.inspect, a2.inspect, a3.inspect)

